﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DA
{
    public class BanThanhPhamDA:BaseConnection
    {
        public SqlDataAdapter danhSachBanThanhPhamAdapter { set; get; }
        public BanThanhPhamDA()
        { 

        }
        public DataSet timKiemBanThanhPham(string maBanThanhPham)
        {
            DataSet ds = new DataSet();
            String sqlStm = "SELECT MaBanThanhPham, DienGiai, SoLuongTonKho";
            sqlStm += " FROM BanThanhPham ";
            sqlStm += " WHERE MaBanThanhPham = '" + maBanThanhPham + "'";

            openConnect();
            SqlCommand cmd = new SqlCommand(sqlStm, con);
            danhSachBanThanhPhamAdapter = new SqlDataAdapter(cmd);
            danhSachBanThanhPhamAdapter.SelectCommand = cmd;
            SqlCommandBuilder sqlBuilder = new SqlCommandBuilder(danhSachBanThanhPhamAdapter);
            danhSachBanThanhPhamAdapter.Fill(ds, "BanThanhPham");
            closeConnect();
            return ds;

        }

        public DataSet layDanhSachBanThanhPham()
        {
            openConnect();
            String sqlStm = "SELECT * FROM BanThanhPham";

            SqlCommand cmd = new SqlCommand(sqlStm, con);
            danhSachBanThanhPhamAdapter = new SqlDataAdapter(cmd);
            danhSachBanThanhPhamAdapter.SelectCommand = cmd;
            SqlCommandBuilder sqlBuilder = new SqlCommandBuilder(danhSachBanThanhPhamAdapter);
            DataSet ds = new DataSet();
            danhSachBanThanhPhamAdapter.Fill(ds, "CongNhan");
            closeConnect();
            return ds;

        }
    }
}

